using System;
using Microsoft.SPOT;

namespace CodeConsult.Nordic.nRF8001.ApplicationControlInterface.Events.CommandResponseEvents
{
    public abstract class AciCommandReponseBase
    {
        protected static DecodeHelper DecodeHelper { get; } = new DecodeHelper();

        public bool Decoded { get; protected set; }
        public bool Error { get; protected set; }

        protected abstract void DecodeFromBuffer();

        internal virtual void Decode(byte[] reponseData)
        {
            if (Decoded || Error) return;

            DecodeHelper.Buffer = reponseData;

            DecodeFromBuffer();

            Error = Error || DecodeHelper.Error;
            Decoded = true;
        }
    }
}
